<template>
  <el-form ref="form" class="form" label-width="80px">
    <p>
      账号
      <el-input v-model="userName" placeholder="请输入账号"></el-input>
    </p>
    <p>
      密码
      <el-input
        placeholder="请输入密码"
        v-model="password"
        show-password
      ></el-input>
    </p>
    <p>
      密码
      <el-input
        placeholder="请再次输入密码"
        v-model="confirmPsd"
        show-password
      ></el-input>
    </p>
    <el-button type="primary" @click="registerEvt">注册</el-button>
  </el-form>
</template>

<script>
import { userRegister } from "../../api/login";

export default {
  data() {
    return {
      userName: "",
      password: "",
      confirmPsd: "",
    };
  },

  methods: {
    registerEvt() {
      userRegister({ userName: this.userName, password: this.password }).then(
        (res) => {
          console.log(res);
          if (res.ok === 1) {
            alert("注册成功");
            this.$router.push("/userlogin/login");
          }
        }
      );
    },
  },
};
</script>

<style lang='scss' scoped>
.form {
  height: 250px;
  width: 420px;
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  margin: auto;
  text-align: center;
}

.el-input {
  width: 90%;
  margin-top: 14px;
}
.el-button {
  margin-top: 10px;
}
</style>
